package cn.bytecollege.admin.controller; /**
 * @Auther：MR.P
 * @Date:2021/10/29 09 03
 * @Description:根据支付方式Id删除支付方式，如果该支付方式下存在支付方式则不允许删除
 */

import cn.bytecollege.admin.service.PaymentService;
import cn.bytecollege.admin.service.ProductService;
import cn.bytecollege.common.entity.Product;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "PaymentDeleteController", value = "/admin/paymentDelete")
public class PaymentDeleteController extends HttpServlet {
    private PaymentService  paymentService = null;

    public PaymentDeleteController(){
        paymentService = new PaymentService();

    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String msg = null;
        String id = request.getParameter("paymentId");
        Integer paymentId = Integer.valueOf(id);
        //通过id删除支付方式
        paymentService.deletePaymentById(paymentId);
        response.sendRedirect(request.getContextPath()+"/admin/paymentList");
    }
}
